/*
 * Copyright (c) 2022, tyustli
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-02-08     tyustli      first implementation
 */

#include <stdio.h>
#include <math.h>

static char armstrong(int value)
{
    int sum = 0;
    int rem = 0;

    int temp_value = value;
    rem = value % 10;

    while (value != 0)
    {
        sum += pow(value % 10, rem);
        value /= 10;
    }

    if (sum == temp_value)
        return 1;
    else
        return 0;
}

int main(int argc, char **argv)
{

    printf("1 is %d\r\n", armstrong(1));
    printf("153 is %d\r\n", armstrong(153));
    printf("1634 is %d\r\n", armstrong(1634));
    printf("1635 is %d\r\n", armstrong(1635));

    return 0;
}

/******************** end of file **********************/
